package com.jwater.core.manager.common;

import java.util.Arrays;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jwater.core.metrics.JvmMetric;
import com.jwater.core.metrics.SystemMetric;

/**
 * @description:
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public class MetricMain {
    protected static Logger logger = LoggerFactory.getLogger(MetricMain.class);

    public static void main(String[] args) throws Exception {
        logger.info("args:" + Arrays.toString(args));
        boolean run = "true".equals(args[0]);
        logger.info(System.getenv("AAA"));
        do {
            logger.info(JvmMetric.pid() + "");
            logger.info(JvmMetric.cpuCount() + "");
            logger.info(JvmMetric.getHeapMemory() + "");
            logger.info(JvmMetric.getNonHeapMemory() + "");
            logger.info(JvmMetric.getThreadCount() + "");
            logger.info(JvmMetric.getThreadStateCount() + "");
            logger.info(JvmMetric.getGcInfo() + "");

            logger.info(SystemMetric.getCpuUsage() + "");
            logger.info(SystemMetric.getAllCpuUsage() + "");
            logger.info(SystemMetric.getDiskRate() + "");
            logger.info(SystemMetric.getFileSystemSpace() + "");
            logger.info(SystemMetric.getHosts() + "");
            logger.info(SystemMetric.getNetRate() + "");
            logger.info(SystemMetric.getSystemMemory() + "");
            logger.info(SystemMetric.getUsedPort() + "");
            if (run) {
                Thread.sleep(10000);
            }
        } while (run);
    }

}
